//Page Object
Page({
  data: {
    tabs: [
      {
        index: 0,
        value: "全部",
        isActive: true
      },
      {
        index: 1,
        value: "待付款",
        isActive: false
      },
      {
        index: 2,
        value: "待发货",
        isActive: false
      },
      {
        index: 3,
        value: "退款/退货",
        isActive: false
      }],
    type: 1
  },
  // onLoad: function (options) {
  //   this.setData({
  //     type: options.type - 1
  //   })
  // },
  onShow () {
    let currentPages = getCurrentPages();
    // console.log(currentPages);
    const current = currentPages[currentPages.length - 1].options.type

    this.setData({
      type: current
    })
    this.setActive()

  },
  // 
  handleTabsTap (e) {
    const { index } = e.detail
    console.log(index);
    let tabs = this.data.tabs
    tabs.forEach(item => {
      if (item.index === index) {
        item.isActive = true
      }
      else {
        item.isActive = false
      }

    })
    this.setData({
      tabs
    })

  },
  setActive () {
    let tabs = this.data.tabs
    tabs.forEach(item => {
      if (item.index === this.data.type - 1) {
        item.isActive = true
      }
      else {
        item.isActive = false
      }
    })
    this.setData({
      tabs
    })
  }

});
